CXX := g++
CXXFLAGS := -std=c++17 -Wall -g
SRCS = main.cpp
ELFS = $(SRCS:.cpp=)

all: $(ELFS)

$(EXE): $(OBJS)
	$(CXX) $(CXXFLAGS) $^ -o $@

%: %.cpp
	$(CXX) $(CXXFLAGS) $< -o $@

clean:
	rm -f ./main input.txt output.txt

ifeq (run,$(firstword $(MAKECMDGOALS)))
  ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
  $(eval $(ARGS):;@:)
endif

run: all
	python3 input.py $(ARGS)
	time ./main

.PHONY: all clean run